home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / include_file.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  68 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. #include "rec.h"
  23. #include "buffer.h"
  24.  
  25. /******************************************************************************\
  26. |Routine: include_file
  27. |Callby: command
  28. |Purpose: Includes an entire file in the current window.
  29. |Arguments:
  30. |    filename is the name of the file to include.
  31. |    binary is a flag indicating the file in to be read in in binary mode.
  32. \******************************************************************************/
  33. void include_file(filename,binary)
  34. Char *filename;
  35. Char binary;
  36. {
  37.     rec_ptr nullrec;
  38.     buf_node buf;
  39.     Char buffer[512],dummy[512],*filebuf,ddummy;    /* dummy[] gets bookmark file name, which is ignored. this is probably a bug. */
  40.     Int idummy,jdummy;
  41.  
  42.     buf.first = (rec_ptr)&buf.first;
  43.     buf.last = (rec_ptr)&buf.first;
  44.     buf.direction = 1;
  45.     if(!(buf.nrecs = load_file(filename,(rec_ptr)&buf.first,dummy,&idummy,&jdummy,&ddummy,binary,&filebuf)))
  46.         return;
  47.     if(buf.nrecs > 0)
  48.     {
  49.         nullrec = (rec_ptr)imalloc(sizeof(rec_node));
  50.         nullrec->length = 0;
  51.         nullrec->data = NULL;
  52.         insq(nullrec,buf.last);
  53.         buf.nrecs++;
  54.         insert(&buf);
  55.         buffer_empty(&buf);
  56.         if(filebuf)
  57.             unmap_file(filebuf);
  58.     }
  59.     else if(buf.nrecs == -1)
  60.     {
  61.         sprintf(buffer,"Unable to open the file %s.",filename);
  62.         slip_message(buffer);
  63.         wait_message();
  64.     }
  65. /* otherwise, it was an ftp error (load_file returns -2) which has already been reported to user */
  66. }
  67.  
  68.